UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

34 lines (32 loc) 834 B
import { AllResponse, createEffectAPIRoutes, createJsonResponse, Effect, genLogger, OptionsResponse, } from '../../../../effect.js'; import { OAuthAPIEffect } from './_effects/index.js'; export const { GET, OPTIONS, ALL } = createEffectAPIRoutes( { GET: (ctx) => genLogger('studiocms/routes/api/auth/[provider]/callback.GET')(function* () { const { initCallback } = yield* OAuthAPIEffect; return yield* initCallback(ctx); }).pipe(OAuthAPIEffect.Provide), OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ['GET'] })), ALL: () => Effect.try(() => AllResponse()), }, { cors: { methods: ['GET', 'OPTIONS'] }, onError: (error) => { console.error('API Error:', error); return createJsonResponse( { error: 'Internal Server Error' }, { status: 500, } ); }, } );